import { BasicColumn, BasicTable, FormSchema, useRender, useTable } from "@/components/Table";
import { useTranslation } from "react-i18next";
import Toolbar from "@/components/ViewComponents/Toolbar";
import { pmtHistoryPage } from "@/api/MedicalExamination";

export default function index() {
	const { t } = useTranslation();

	const columns: BasicColumn[] = [
		{
			title: t("patientBasic.patient_id"),
			dataIndex: "patientId",
			render: (_, record) => (record.patients ? record.patients.patientId : "")
		},
		{
			title: t("patientBasic.full_name"),
			dataIndex: "fullName",
			render: (_, record) => (record.patients ? record.patients.fullName : "")
		},
		{
			title: t("patientBasic.birthyear"),
			dataIndex: "birthday",
			render: (_, record) => (record.patients ? record.patients.birthday : "")
		},
		{
			title: t("patientBasic.pat_type"),
			dataIndex: "patientType"
		},
		{
			title: t("kevin_ui.admission_date"),
			dataIndex: "admissionDate",
			render: (_, record) => (record.ipmAdmissions ? useRender.renderDate(record.ipmAdmissions.dateAdmission) : "")
		},
		{
			title: t("kevin_ui.discharge"),
			dataIndex: "dischargeDate",
			render: (_, record) => (record.ipmAdmissions ? useRender.renderDate(record.ipmDischarges.dcDtime) : "")
		},
		{
			title: t("patientBasic.card_number"),
			dataIndex: "cardNumber",
			render: (_, record) => (record.patients ? record.patients.patCardno : "")
		},
		{
			title: t("patientBasic.pat_address"),
			dataIndex: "address"
		}
	];
	const searchFormSchema: FormSchema[] = [
		{
			label: "Daily Form",
			field: "Daily Form",
			component: "Checkbox",
			colProps: { span: 8 }
		},
		{
			label: "Form 01",
			field: "Form 01",
			component: "Checkbox",
			colProps: { span: 8 }
		},
		{
			label: "Form 02",
			field: "Daily Form",
			component: "Checkbox",
			colProps: { span: 8 }
		},
		{
			label: "Status",
			field: "Status",
			component: "Select"
		},
		{
			label: t("patientBasic.patient_id"),
			field: "patientId",
			component: "Input"
		},
		{
			label: t("patientBasic.full_name"),
			field: "Full Name",
			component: "Input"
		},
		{
			label: "Admission Date",
			field: "Admission Date",
			component: "DatePicker"
		},
		{
			label: "From Date",
			field: "From Date",
			component: "DatePicker"
		},
		{
			label: "To Date",
			field: "To Date",
			component: "DatePicker"
		},
		{
			label: "Department",
			field: "Department",
			component: "Input"
		},
		{
			label: "Object",
			field: "Object",
			component: "Input"
		},
		{
			label: "Citizen Code",
			field: "Citizen Code",
			component: "Input"
		},
		{
			label: "Allowance",
			field: "Allowance",
			component: "Input"
		},
		{
			label: "Receipt",
			field: "Receipt",
			component: "Input"
		},
		{
			label: "Home Address",
			field: "Home Address",
			component: "Input"
		}
	];
	const [patServicesTable] = useTable({
		// dataSource: [
		// 	{
		// 		patientId: "123131",
		// 		fullName: "Jack",
		// 		birthday: "2025-01-23",
		// 		patientType: "1",
		// 		admissionDate: "2025-01-23",
		// 		dischargeDate: "2025-01-23",
		// 		cardNumber: "1231231",
		// 		address: "NanJing"
		// 	}
		// ],
		api: pmtHistoryPage,
		columns,
		useSearchForm: true,
		formConfig: {
			labelWidth: 120,
			schemas: searchFormSchema,
			showActionButtonGroup: true,
			baseColProps: { span: 8 }
		},
		rowSelection: { type: "checkbox" }
	});

	return (
		<div className="page508 page">
			<div className="page-content">
				<BasicTable register={patServicesTable}></BasicTable>
			</div>
			<Toolbar btnList={["print"]}></Toolbar>
		</div>
	);
}
